import {createRouter, createWebHashHistory, RouteRecordRaw} from 'vue-router';
import {afterEach, beforeEach} from './hook';

const routes: Array<RouteRecordRaw> = [];

const pages = import.meta.globEager('../example/**/*.vue');

Object.entries(pages).forEach(([key, val]: any) => {
  routes.push({
    path: key.replace(/\.vue|\.\./g, ''),
    component: val.default
  });
});

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

beforeEach(router);
afterEach(router);

export default router;
